/**
 ***********************************************************
 * Original Code:
 *
 * Software License Agreement (BSD License)
 *
 *  Copyright (c) 2009, Willow Garage, Inc.
 *  All rights reserved.
 *
 ***********************************************************
 *
 * @file	voiceExample.cpp
 * @author	Michiel Hegemans
 * @author	Peter Evers
 * @date	November 15, 2012
 * @brief	Voice example file
 *
 * Says a simple sentence as example.
 */

#include <sound_play/sound_play.h>
#include <unistd.h>
#include "topic/topic.h"

void sleepok(int t, ros::NodeHandle &nh) {
	if (nh.ok()) {
		sleep(t);
	}
}

int main(int argc, char **argv) {
	ros::init(argc, argv, "voice_test");
	std::string topic = "robotsound";

	sound_play::SoundClient sc;
	ros::NodeHandle nh;
	ros::Publisher pub_ = nh.advertise<sound_play::SoundRequest>(topic, 5);
	sleepok(1,nh);

	while (nh.ok()) {
		ROS_INFO("Number of subscribers: %i", pub_.getNumSubscribers());
		ROS_INFO("Topic: %s", pub_.getTopic().c_str());

		sc.say("Hello Dave", "voice_cmu_us_slt_arctic_hts");
		sleepok(2,nh);
		sc.say("Hello", "voice_kal_diphone");
		sleepok(1,nh);
		sc.say("How are you", "voice_cmu_us_slt_arctic_hts");
		sleepok(2,nh);
		sc.say("Prepare your diddly hole", "voice_kal_diphone");
		sleepok(3,nh);
		sc.say("No never!", "voice_cmu_us_slt_arctic_hts");
		sleepok(2,nh);
		return 0;
	}


	return 0;
}
